package com.mrlv.rabbitmq.utilts;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * @author Mrlv
 * @version 1.0
 * @description: TODO
 * @date 2021年11月19日 23:53
 */
public class RabbitMqUitls {

    //得到一个链接
    public static Channel getChannel() throws Exception {
        //创建一个连接工厂
        ConnectionFactory connectionFactory = new ConnectionFactory();
        //工站IP 连接 RedisMQ 的队列
        connectionFactory.setHost("127.0.0.1");
        //用户名
        connectionFactory.setUsername("guest");
        //密码
        connectionFactory.setPassword("guest");
        //创建连接
        Connection connection = connectionFactory.newConnection();
        //获取信道
        Channel channel = connection.createChannel();
        return channel;
    }
}
